package cn.edu.neusoft.maxingxin231.yuejian06.Fragment;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Adapter.CoachAdapter;
import cn.edu.neusoft.maxingxin231.yuejian06.Adapter.FinishOrderAdapter;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.OrderListBean;
import cn.edu.neusoft.maxingxin231.yuejian06.Listener.ListListener;
import cn.edu.neusoft.maxingxin231.yuejian06.Model.OrderListModel;
import cn.edu.neusoft.maxingxin231.yuejian06.R;

/**
 * A simple {@link Fragment} subclass.

 */
public class FinishOrderFragment extends BaseFragment {
    RecyclerView recyclerview;
    private List<OrderListBean> items;
    String order_id,user_id;

    ListListener<OrderListBean> orderListBeanListListener = new ListListener<OrderListBean>() {
        @Override
        public void onResponse(List<OrderListBean> list) {
            items = list;
            FinishOrderAdapter finishOrderAdapter = new FinishOrderAdapter(getActivity(),items,R.layout.order_card);
            recyclerview.setAdapter(finishOrderAdapter);
            recyclerview.setItemAnimator(new DefaultItemAnimator());
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(getActivity(), "error11", Toast.LENGTH_SHORT).show();
        }
    };
    @Override
    protected void initView() {
       recyclerview = (RecyclerView)view.findViewById(R.id.recyclerview);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerview.setLayoutManager(layoutManager);


    }

    @Override
    void initEvent() {
        OrderListModel orderListModel = new OrderListModel();
        orderListModel.getFinishOrder(getUser_id(),orderListBeanListListener);
    }

    @Override
    void initData() {

    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        setLayout_file(R.layout.fragment_finish_order);
        return super.onCreateView(inflater,container,savedInstanceState);
    }

    public interface OnFragmentInteractionListener {
        // TODO: Update argument type and name
        void onFragmentInteraction(Uri uri);
    }
}
